//
// Created by Wirano on 2020/11/10.
//

#include "include.h"
#include "Drv_pwm_out.h"
#include "Drv_led.h"
#include "Drv_spi.h"
#include "Drv_icm20602.h"
#include "Drv_ak8975.h"
#include "Drv_spl06.h"
#include "Drv_w25qxx.h"
#include "Drv_i2c_soft.h"
#include "Ano_FlightCtrl.h"
#include "Drv_adc.h"
#include "Drv_heating.h"
#include "Ano_RC.h"
#include "Ano_Sensor_Basic.h"
#include "Drv_UP_Flow.h"

#include "Nizhou_drv_TOF.h"
#include "Nizhou_drv_T265.h"



uint8_t of_init_type;
uint8_t All_Init()
{
////    NVIC_PriorityGroupConfig(NVIC_GROUP);		//中断优先级组别设置
////
////    SysTick_Configuration(); 		//滴答时钟
//
    HAL_Delay(100);			//延时
    //不建议改动
    Drv_LED_Init();					//LED功能初始化
    //不建议改动
    Flash_Init();             		//板载FLASH芯片驱动初始化
    //不建议改动
    Para_Data_Init();              		//参数数据初始化 不建议改动

    Remote_Control_Init();//这个函数已经没用了

    PWM_Out_Init();					//初始化电调输出功能	
    HAL_Delay(100);					//延时

    //关于传感器部分的都不建议改动
//  Drv_SPI2_init();          		//spi_2初始化 在HAL库中已经完成初始化
    Drv_Icm20602CSPin_Init(); 		//spi片选初始化
    Drv_AK8975CSPin_Init();   		//spi片选初始化

    Drv_SPL06CSPin_Init();    		//spi片选初始化
    sens_hd_check.gyro_ok = sens_hd_check.acc_ok =
            Drv_Icm20602Reg_Init();//icm陀螺仪加速度计初始化，若初始化成功，则将陀螺仪和加速度的初始化成功标志位赋值
    sens_hd_check.mag_ok = 1;//标记罗盘OK
    sens_hd_check.baro_ok = Drv_Spl0601_Init();//气压计初始化

    Drv_AdcInit();//不建议改动
    HAL_Delay(100);//延时

    All_PID_Init();//PID初始化 不建议改动；
    HAL_Delay(50);//延时

    Drv_HeatingInit();//不建议改动
    Sensor_Basic_Init();

    //自己添加的
    TOF_Init();//TOF初始状态检测函数
    T265_Init();


    ANO_DT_SendString("SYS init OK!");//使用了串口进行发送

    //NOTE:此处需要添加OPMV相关的状态函数
    ANO_DT_SendString("OMV init");

    return (1);
}

